#简单的多线程程序
import threading
import time

class CrawlingThread(threading.Thread):#继承threading.Thread类具备线程功能，任务是打印“写爬虫”
    def run(self):#当线程启动后，会自动执行run方法中的代码。
        for x in range(3):
            print('%s 正在写爬虫' % threading.current_thread())#返回当前线程对象
            time.sleep(1)

class VisitingThread(threading.Thread):
    def run(self):
        for x in range(3):
            print('%s 正在访问网页' % threading.current_thread())
            time.sleep(1)

def multi_thread():
    t1 = CrawlingThread()
    t2 = VisitingThread()
    t1.start()
    t2.start()

if __name__ == '__main__':
    multi_thread()